package org.vectrics.project.tags;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.vectrics.common.pagelist.PageList;
import org.vectrics.project.task.TaskCriteria;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.user.Person;

public class TaskPageList extends PageList {
	private Person person = null;
	private Set statusTypeCodes = new HashSet();
	
	private TaskCriteria taskCriteria = null;
	
	public TaskPageList() {
		super();
	}

	private TaskCriteria getTaskCriteria() {
		taskCriteria = new TaskCriteria();
		taskCriteria.setPerson(person);
		taskCriteria.setStatusTypeCodes(this.statusTypeCodes);
		return(taskCriteria);
	}
	
	public void addStatusType(String statusTypeCode) {
		this.statusTypeCodes.add(statusTypeCode);
	}
	
	public int getTotalElementCount() {
		return CoreServiceLocator.getProjectService().findTaskCount(getTaskCriteria());
	}

	public List getElements(int start, int end) {
		return CoreServiceLocator.getProjectService().findTasks(getTaskCriteria(), start, end);
	}
}
